<?
//package junit.runner;

//import java.util.*;

//import junit.runner.*;

/**
 * A custom quick sort with support to customize the swap behaviour.
 * NOTICE: We can't use the the sorting support from the JDK 1.2 collection
 * classes because of the JDK 1.1.7 compatibility.
 */
interface Swapper 
{
	public function swap( Vector $values, $left, $right );
}
	
class Sorter 
{		
	public static function sortStrings( Vector $values , $left, $right, Swapper $swapper ) 
	{ 
		$oleft = $left;
		$oright = $right;
		$mid = (String)$values->elementAt(($left + $right) / 2); 
		do 
		{ 
			while ($values->elementAt($left)->compareTo($mid) < 0)  
				$left++; 
			while ($mid->compareTo((String)($values->elementAt($right))) < 0)  
				$right--; 
			if ($left <= $right) {
				$swapper->swap( $values, $left, $right ); 
				$left++; 
				$right--; 
			} 
		} while ($left <= $right);
		
		if ($oleft < $right) 
			sortStrings( $values, $oleft, $right, $swapper ); 
		if ($left < $oright) 
			 sortStrings( $values, $left, $oright, $swapper ); 
	}
}
?>